package edu.spec.wfl.week09.class2.homework.Three;

import java.util.ArrayList;
import java.util.List;

public class  Student {
    private String name;
    private int age;
    private int score;
    private String classNum;

    public Student(String name, int age, int score, String classNum) {
        this.name = name;
        this.age = age;
        this.score = score;
        this.classNum = classNum;
    }

    public static void main(String[] args) {
        List list = new ArrayList();

        list.add(new Student("Tom", 18, 100, "class05"));  	//参数第一个表示姓名
        list.add(new Student("Jerry", 22, 70, "class04"));//第二个是年龄
        list.add(new Student("Owen", 25, 90, "class05"));//第三个是分数
        list.add(new Student("Jim", 30,80 , "class05"));//第4个是班级
        list.add(new Student("Steve", 28, 66, "class06"));
        list.add(new Student("Kevin", 24, 100, "class04"));

        //在这个list 的基础上，完成下列要求：
        //1） 计算所有学生的平均年龄
        double ave;
        double all=0;
        for (int i=0;i<list.size();i++){
            Student s=(Student)list.get(i);
            all+=s.age;
        }
        ave=all/5;
        System.out.println(ave);
        //2） 计算各个班级的平均分
        double all1=0;
        double all2=0;
        double all3=0;
        double a=0;
        double b=0;
        double c=0;
        for (int i=0;i<list.size();i++){
            Student s1=(Student)list.get(i);
            if(s1.classNum=="class04"){
                all1+= s1.score;
                a++;
            }
           else if(s1.classNum=="class05"){
                all2+= s1.score;
                b++;
            }
            else if(s1.classNum=="class06"){
                all3+= s1.score;
                c++;
            }
        }
        System.out.println(all1/a);
        System.out.println(all2/b);
        System.out.println(all3/c);
    }

}
